<?php
//Ends the users session and logs out
//Remove session and logout
session_start();
$session_name = session_name();
session_destroy();

if ( session_id != "" OR isset( $_COOKIE[ $session_name ] ) ) {
    if ( setcookie(session_name(), '', time()-3600, '/') ) {
        //header("Location: index.php");
        unset($_COOKIE[session_name()]);
        header("Location: ../index.php");
        exit();
    }
    else
    {
        // setcookie() fails when there is output sent prior to calling this function.
    }
}

//iecho "You have successfully logged out\n";

?>

